//
// Created by Asus on 2025/5/31.
//

#include <iostream>
#include <bits/ostream.tcc>
using namespace std;

int add(int a, int b) {
    return a + b;
}

void swap(int num1, int num2)
{
    cout << "交换前：" << endl;
    cout << "num1 = " << num1 << endl;
    cout << "num2 = " << num2 << endl;

    int temp = num1;
    num1 = num2;
    num2 = temp;

    cout << "交换后：" << endl;
    cout << "num1 = " << num1 << endl;
    cout << "num2 = " << num2 << endl;
}

void swap2(int &num1, int &num2)
{
    cout << "交换前：" << endl;
    cout << "num1 = " << num1 << endl;
    cout << "num2 = " << num2 << endl;

    int temp = num1;
    num1 = num2;
    num2 = temp;

    cout << "交换后：" << endl;
    cout << "num1 = " << num1 << endl;
    cout << "num2 = " << num2 << endl;
}

void swap3(int *num1, int *num2)
{
    cout << "交换前：" << endl;
    cout << "num1 = " << *num1 << endl;
    cout << "num2 = " << *num2 << endl;

    int temp = *num1;
    *num1 = *num2;
    *num2 = temp;

    cout << "交换后：" << endl;
    cout << "num1 = " << *num1 << endl;
    cout << "num2 = " << *num2 << endl;
}

void demo01() {
    int a = 10;
    int b = 20;
    // swap(a, b);
    // swap2(a, b);
    swap3(&a, &b);
    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
}

//声明可以多次，定义只能一次
//声明
int max(int a, int b);
int max(int a, int b);
//定义
int max(int a, int b)
{
    return a > b ? a : b;
}

int main(char *argv[]) {
    demo01();
    return 0;
}
